Parse.Cloud.define('getRolesAll', async (req, res) => {
  const user = req.user
  if (!user) {
    return res.error('请先登录')
  }
  const permission = { sessionToken: user.getSessionToken() }
  const queryRole = new Parse.Query(new Parse.Role())
  try {
    const result = await queryRole.find(permission)
    const data = result.map(item => {
      const obj = {}
      obj.name = item.get('name')
      obj.id = item.id
      return obj
    })
    res.success({
      data
    })
  } catch (err) {
    console.log(err)
    res.error(err.message)
  }
})
